home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performClearKeyArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  13.8 KB  |  488 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  August 14, 1996
  22. //
  23. //  Description:
  24. //      This is a helper script to perfrom the cutKey -clear command
  25. //    using the various options that have been set
  26. //
  27. //  Input Arguments:
  28. //        int action        0 - just execute the command
  29. //                        1 - show the option box dialog
  30. //                        2 - return the drag command
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36. proc setOptionVars (int $forceFactorySettings)
  37. {
  38.     keySetOptionBoxCommon( { "clearKey", 
  39.                              "unknown",
  40.                              "setOptionVars", 
  41.                              $forceFactorySettings,
  42.                              1 } );
  43.  
  44.     // -options
  45.     //
  46.     if ($forceFactorySettings || !`optionVar -exists clearKeyOption`) {
  47.         optionVar -stringValue clearKeyOption "keys";
  48.     }
  49.     // help images
  50.     //
  51.     if ($forceFactorySettings || !`optionVar -exists clearKeyHelpPictures`) {
  52.         optionVar -intValue clearKeyHelpPictures 0;
  53.     }
  54. }
  55.  
  56. global proc clearKeySetup (string $parent, string $selectionConnection, int $forceFactorySettings)
  57. {
  58.     // Retrieve the option settings
  59.     //
  60.     setOptionVars( $forceFactorySettings );
  61.  
  62.     setParent $parent;
  63.  
  64.     keySetOptionBoxCommon( { "clearKey", $selectionConnection, "setup", 1 } );
  65.  
  66.     // -option
  67.     //
  68.     string $option = `optionVar -query clearKeyOption`;
  69.     int $attach = 1;
  70.     int $connect = 0;
  71.  
  72.     if (substring ($option, 1, 4) == "keys") {
  73.         radioButtonGrp -edit -select 1 method;
  74.     }
  75.     else {
  76.         radioButtonGrp
  77.             -edit
  78.             -select 2
  79.             method;
  80.         if ($option == "curveCollapse") {
  81.             $attach = 2;
  82.         }
  83.         else if ($option == "curveConnect") {
  84.             $attach = 2;
  85.             $connect = 1;            
  86.         }
  87.     }
  88.     radioButtonGrp -edit -select $attach adjustment;
  89.     checkBoxGrp -e -value1 $connect connect;
  90.  
  91.     // help images
  92.     //
  93.     int $pictures = `optionVar -q clearKeyHelpPictures`;
  94.     checkBoxGrp -e -value1 $pictures helpPictures;
  95.  
  96.     // Now get all the dependent widgets in the right 
  97.     // enabled/disabled/collapsed/expanded state
  98.     //
  99.     clearKeyWidgetsEnable ($selectionConnection);
  100. }
  101.  
  102. global proc clearKeyCallback( string $parent, int $doIt,
  103.                               string $selectionConnection, 
  104.                               int $fromGraphEditor, 
  105.                               int $performAction )
  106. {
  107.     setParent $parent;
  108.  
  109.     keySetOptionBoxCommon( { "clearKey", $selectionConnection, "callback" } );
  110.  
  111.     // -option
  112.     string $option;
  113.     if (`radioButtonGrp -query -select method` == 1) {
  114.         $option = "keys";
  115.     }
  116.     else {
  117.         $option = "curve";
  118.     }
  119.     if (`radioButtonGrp -query -select adjustment` == 2) {
  120.         if( `checkBoxGrp -query -value1 connect` ) {
  121.             $option = $option + "Connect";
  122.         } else {
  123.             $option = $option + "Collapse";
  124.         }
  125.     }
  126.     optionVar -stringValue clearKeyOption $option;
  127.  
  128.     // help
  129.     //
  130.     int $pictures = `checkBoxGrp -query -value1 helpPictures`;
  131.     optionVar -intValue clearKeyHelpPictures $pictures;
  132.  
  133.  
  134.     if( $doIt ) {
  135.         string $args[] = { (string) $performAction,
  136.                            $selectionConnection,
  137.                            (string) 0,
  138.                            (string) $fromGraphEditor };
  139.  
  140.         performClearKeyArgList 1 $args;
  141.         string $tmpCmd = "{\"" + $performAction + "\", \"" + $selectionConnection + "\", ";
  142.         $tmpCmd += "0, \"" + $fromGraphEditor + "\"}";
  143.         addToRecentCommandQueue $tmpCmd "ClearKey";
  144.     }
  145. }
  146.  
  147. global proc clearKeyHelpPictures ()
  148. {
  149.     int $doPictures = (`checkBoxGrp -q -value1 helpPictures` &&
  150.                        `checkBoxGrp -q -enable helpPictures`);
  151.  
  152.     if( $doPictures == 0 ) {
  153.         frameLayout -e -collapse yes methodPictureFrame;
  154.         frameLayout -e -collapse yes adjustmentPictureFrame;
  155.         return;
  156.     }
  157.  
  158.     int $method = `radioButtonGrp -q -select method`;
  159.     int $adjustment = `radioButtonGrp -q -select adjustment`;
  160.  
  161.     string $adjustmentPicture = "CCP";
  162.     string $methodPicture;
  163.  
  164.     if( $method == 1 ) {
  165.         $adjustmentPicture = $adjustmentPicture + "cutKeys";
  166.     } else {
  167.         $adjustmentPicture = $adjustmentPicture + "cutCurve";
  168.     }
  169.  
  170.     $methodPicture = "CCPclear.xpm";
  171.  
  172.     if( $adjustment == 2 ) {
  173.         if( `checkBoxGrp -q -value1 connect` ) {
  174.             $adjustmentPicture = $adjustmentPicture + "Connect.xpm";
  175.         } else {
  176.             $adjustmentPicture = $adjustmentPicture + "Collapse.xpm";
  177.         }
  178.     } else {
  179.         $adjustmentPicture = $adjustmentPicture + ".xpm";
  180.     } 
  181.  
  182.     picture -e -image $methodPicture methodPicture;
  183.     picture -e -image $adjustmentPicture adjustmentPicture;
  184.  
  185.     frameLayout -e -collapse no methodPictureFrame;
  186.     frameLayout -e -collapse no adjustmentPictureFrame;
  187. }
  188.  
  189. global proc clearKeyDoSelectionChanged (string $selectionConnection)
  190. //
  191. // Description:
  192. //    Since timeRange is irrelevant when there are 
  193. //    picked keyframes, collapse the timeRange
  194. //    when there are.  (This is hooked in to a SelectionChanged
  195. //    trigger.)
  196. //    
  197. {
  198.     keySetOptionBoxCommon( { "clearKey", $selectionConnection, "selectionChanged" } );
  199.  
  200.     if( `keyframe -q -sl -kc` > 0) {
  201.         radioButtonGrp -e -enable2 false -select 1 method;
  202.         radioButtonGrp -e -enable2 false -select 1 adjustment;
  203.     } else if( `radioButtonGrp -q -enable method` ) {
  204.         radioButtonGrp -e -enable2 true method;
  205.     }
  206. }
  207.  
  208.  
  209. global proc clearKeyWidgetsEnable (string $selectionConnection)
  210. //
  211. // Description:
  212. //    These are the widgets that get enabled and
  213. //    disabled based on the certain states.  Put them
  214. //    here so they're all in one place.
  215. //    
  216. {
  217.     keySetOptionBoxCommon( { "clearKey", $selectionConnection, "enable" } );
  218.  
  219.     // Options frame
  220.     //
  221.     int $enableIt = ( `radioButtonGrp -q -select timeRange` != 1 );
  222.     frameLayout -e -enable $enableIt optionsFrame;
  223.  
  224.     // Collapse adjustment
  225.     //
  226.     $enableIt = (( `radioButtonGrp -q -select method` == 2 ) &&
  227.                   ( `radioButtonGrp -q -enable2 method` ));
  228.     radioButtonGrp -e -enable2 $enableIt adjustment;
  229.     if( !$enableIt && `radioButtonGrp -q -enable method` ) {
  230.         radioButtonGrp -e -select 1 adjustment;
  231.     }
  232.  
  233.     // Connect check box
  234.     //
  235.     $enableIt = (( `radioButtonGrp -q -select adjustment` == 2 ) &&
  236.                  ( `radioButtonGrp -q -enable2 adjustment` ));
  237.     checkBoxGrp -e -enable $enableIt connect;
  238.  
  239.     clearKeyHelpPictures;
  240. }
  241.  
  242. proc string clearKeyWidgets( string $tabLayout, string $selectionConnection, int $fromGraphEditor )
  243. {
  244.     global int $gOptionBoxTextColumnWidthIndex;
  245.  
  246.     setParent $tabLayout;
  247.  
  248.     string $tabForm = `columnLayout -adjustableColumn true`;
  249.  
  250.     keySetOptionBoxCommon( { "clearKey", $selectionConnection, "widgets", $fromGraphEditor, 1 } );
  251.     
  252.     frameLayout -bv no -lv no -collapsable no optionsFrame;
  253.         columnLayout -adjustableColumn true;
  254.  
  255.             checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 "" 
  256.                 -cc1 "clearKeyHelpPictures;" 
  257.                 helpPictures;
  258.  
  259.             radioButtonGrp -numberOfRadioButtons 2 -label "Method" 
  260.                 -label1 "Keys" 
  261.                 -cc1 ("clearKeyWidgetsEnable " + $selectionConnection)
  262.                 -label2 "Segments" 
  263.                 -cc2 ("clearKeyWidgetsEnable " + $selectionConnection) method;
  264.  
  265.             frameLayout -bv no -lv no -collapsable yes -collapse yes 
  266.                 methodPictureFrame;
  267.  
  268.                 columnLayout -columnAttach "left" $gOptionBoxTextColumnWidthIndex;
  269.                     picture methodPicture;
  270.  
  271.                     setParent ..;
  272.                 setParent ..;
  273.  
  274.             radioButtonGrp -numberOfRadioButtons 2 -label "Adjustment" 
  275.                 -label1 "None" 
  276.                 -cc1 ("clearKeyWidgetsEnable " + $selectionConnection)
  277.                 -label2 "Collapse" 
  278.                 -cc2 ("clearKeyWidgetsEnable " + $selectionConnection)
  279.                 adjustment;    
  280.  
  281.             checkBoxGrp -label "Connect" -ncb 1 -l1 "" -value1 off 
  282.                 -cc1 "clearKeyHelpPictures;" connect;
  283.  
  284.             frameLayout -bv no -lv no -collapsable yes -collapse yes 
  285.                 adjustmentPictureFrame;
  286.  
  287.                 columnLayout -columnAttach "left" 
  288.                     $gOptionBoxTextColumnWidthIndex;
  289.  
  290.                     picture adjustmentPicture;
  291.  
  292.                     setParent ..;
  293.                 setParent ..;
  294.  
  295.             setParent ..;
  296.  
  297.         setParent ..;
  298.  
  299.     return $tabForm;
  300. }
  301.  
  302. proc clearKeyOptions( string $selectionConnection, 
  303.                       int $performAction, 
  304.                       int $fromGraphEditor )
  305. {
  306.  
  307.  
  308.  
  309.     // Customisation options
  310.     //
  311.     // Name of the command for this option box (think of it as the base class)
  312.     string $commandName = "clearKey";
  313.     // Title for the option box window
  314.     string $optionBoxTitle;
  315.     string $applyTitle;
  316.  
  317.     $optionBoxTitle = "Delete Keys Options";
  318.     $applyTitle = "Delete keys";
  319.  
  320.     // Build the option box "methods"
  321.     //
  322.     string $callback = ($commandName + "Callback");
  323.     string $setup = ($commandName + "Setup");
  324.  
  325.     // Build the window, with a tab layout
  326.     //
  327.     string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`;
  328.     setUITemplate -pushTemplate DefaultTemplate;
  329.  
  330.     // Make the form invisible while we create the widgets in the window
  331.     //
  332.     formLayout -e -vis false $widgetList[1];
  333.  
  334.     // Attach the widgets.  No tab layout needed.
  335.     //
  336.     clearKeyWidgets $widgetList[2] $selectionConnection $fromGraphEditor ;
  337.  
  338.     // Attach the standard buttons
  339.     //
  340.     string $buttonList[] = `addStandardButtons $commandName $applyTitle 
  341.         $widgetList[1] $widgetList[2] "noOptions"`;
  342.  
  343.     // attach commands to the standard buttons
  344.     //
  345.     // Save
  346.     //
  347.     button -e -c ($callback + " " + $widgetList[0] + " false \"\" " +
  348.                   $fromGraphEditor + " " + $performAction 
  349.                   + "; hideOptionBox()") $buttonList[3];
  350.  
  351.     // Close
  352.     //
  353.     button -edit -command hideOptionBox $buttonList[2];
  354.  
  355.     // Reset
  356.     //
  357.     button -edit -command ($setup + " " + $widgetList[0] + " " + $selectionConnection + " true") $buttonList[1];
  358.  
  359.     // DoIt
  360.     //
  361.     button -edit -c ($callback + " " + $widgetList[0] + " true \"" + 
  362.                      $selectionConnection + "\" " + 
  363.                      $fromGraphEditor + " " + $performAction) $buttonList[0];
  364.  
  365.     // Make the form layout visible so we can see what we built, and
  366.     // reset the template
  367.     //
  368.     formLayout -e -vis true $widgetList[1];
  369.     setUITemplate -popTemplate;
  370.  
  371.     //    Customize the 'Help' menu item text.
  372.     //    This is called from 3 different places so look at the selection
  373.     //    connection to try to figure out which one.
  374.     //
  375.     if (match ("graphEditor", $selectionConnection) != "") {
  376.         setOptionBoxHelpTag( "GraphDelete" );
  377.     } else if (match ("dopeSheet", $selectionConnection) != "") {
  378.         setOptionBoxHelpTag( "DopeDelete" );
  379.     } else {
  380.         setOptionBoxHelpTag( "KeysDeleteKeys" );
  381.     }    
  382.  
  383.     if( $fromGraphEditor ) {
  384.         clearKeyDoSelectionChanged($selectionConnection);    
  385.         scriptJob -protected -event "SelectionChanged" 
  386.             ("clearKeyDoSelectionChanged " + $selectionConnection + "; clearKeyWidgetsEnable " + $selectionConnection + ";")
  387.             -parent $widgetList[2];
  388.     }
  389.  
  390.     // Call the setup "method" to fill in the current settings
  391.     //
  392.     eval (($setup + " " + $widgetList[0] + " " + $selectionConnection + " false"));    
  393.     showOptionBox();
  394.     showWindow $widgetList[0];
  395. }
  396.  
  397.  
  398. proc string assembleCmd( string $selectionConnection, int $fromGraphEditor,
  399.                          string $options ) 
  400. {
  401.     // doClearKeyArgList takes a string array
  402.     //
  403.     $cmd = "doClearKeyArgList 3 { " + 
  404.                 "\"" + `optionVar -q clearKeyWhichRange` + "\"" + 
  405.                 ",\"" + `optionVar -q clearKeyRange` + "\"" + 
  406.                 ",\"" + `optionVar -q clearKeyOption` + "\"" + 
  407.                 ",\"" + `optionVar -q clearKeyHierarchy` + "\"" + 
  408.                 ",\"" + `optionVar -q clearKeyControlPoints` + "\"" + 
  409.                 ",\"" + `optionVar -q clearKeyShapes` + "\"" + 
  410.                 ",\"" + `optionVar -q clearKeyUseChannelBox` + "\"" + 
  411.                 ",\"" + `optionVar -q clearKeyAllAnimCurves` + "\"" + 
  412.                 ",\"" + $selectionConnection + "\"" + 
  413.                 ",\"0\"" +
  414.                 ",\"" + $options + "\"" +
  415.                 ",\"" + $fromGraphEditor + "\"" +
  416.                 ",\"" + `optionVar -q clearKeyDriven` + "\"" +
  417.             " };";
  418.  
  419.     return $cmd;
  420. }
  421.  
  422. global proc string performClearKeyArgList (string $version, string $args[])
  423. //
  424. //  Input Arguments:
  425. //    $version: The version of this option box.  Used to know how to 
  426. //    interpret the $args array.
  427. //        "1" : $action, $selectionConnection, $unused, $fromGraphEditor
  428. //
  429. //    $args
  430. //    Version 1
  431. //    [0]        $action                    0 - do the command
  432. //                                    1 - show the option box
  433. //                                    2 - return the drag command
  434. //                                    3 - do the command (bufferCurve version)
  435. //                                    4 - show the option box (bufferCurve version)
  436. //                                    5 - return the drag command (bufferCurve version)
  437. //    [1]        $selectionConnection    name of selection connection to use
  438. //                                    unless $options has "bufferCurve" in which
  439. //                                    case this is the name of the editor
  440. //    [2]        $unused                     
  441. //    [3]        $fromGraphEditor        true if being called from the graph editor
  442. //
  443. //  Return Value:
  444. //      The actual command to execute.
  445. //
  446. {
  447.     int        $versionNum                = $version;
  448.  
  449.     int        $action                    = $args[0];
  450.     string    $selectionConnection    = $args[1];
  451.     int        $unused                    = $args[2];
  452.     int        $fromGraphEditor        = $args[3];
  453.  
  454.     string $cmd = "";
  455.  
  456.     switch( $action ) {
  457.     case 0:
  458.         setOptionVars( false );
  459.         $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, 
  460.                             "noOptions");
  461.         eval( $cmd );
  462.         break;
  463.     case 1:
  464.         clearKeyOptions( $selectionConnection, 0, $fromGraphEditor );
  465.         break;
  466.     case 2:
  467.         setOptionVars( false );
  468.         $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, 
  469.                             "noOptions");
  470.         break;
  471.     case 3:
  472.         setOptionVars( false );
  473.         $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, 
  474.                             "bufferCurve");
  475.         eval( $cmd );
  476.         break;
  477.     case 4:
  478.         clearKeyOptions( $selectionConnection, 3, $fromGraphEditor );
  479.         break;
  480.     case 5:
  481.         setOptionVars( false );
  482.         $cmd = assembleCmd ($selectionConnection, $fromGraphEditor, 
  483.                             "bufferCurve");
  484.         break;
  485.     }
  486.     return ($cmd);
  487. }
  488.